import json
import logging

from api.BaseService import BaseService


class UserService(BaseService):
    """
    管理员服务
    """

    def __init__(self):
        super().__init__()
        self.service_name = "UserService"
        logging.info(f"当前远程服务名为{self.service_name}")

    def findByUsername(self, data):
        """
        :param data:需要查找的管理员信息
        :return: 管理员可控制信息
        """
        logging.info(f"当前远程服务名为{self.service_name},远程服务方法为findByUsername")
        logging.info(f"测试数据为{data}")
        resp = self.dubbo_client.invoke(self.service_name, "findByUsername", data)
        logging.info(f"响应结果为{json.loads(resp)}")
        if json.loads(resp) is None:
            resp = None
        else:
            resp = json.loads(resp)
        return resp


if __name__ == '__main__':
    us = UserService()
    print(us.findByUsername("admin"))
